package com.yuan.support;

import android.content.Context;

/**
 * create by
 * on 2021-04-17
 */
public class ContextUtils {
    private static volatile Context sContext;

    public static Context getContextByReflection() {
        if (sContext == null) {
            synchronized (ContextUtils.class) {
                if (sContext == null) {
                    try {
                        sContext = (Context) (Class.forName("android.app.ActivityThread")
                                .getMethod("currentApplication")
                                .invoke(null, (Object[]) null));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

            }
        }
        return sContext;
    }
}
